﻿using System;
using Com.OpenCode.Framework.Core;

namespace Com.OpenCode.Framework.DevForm
{
    /// <summary>
    ///     所有可停靠面板控制命令基类
    /// </summary>
    public abstract class DockPanelCommand : AbstractCommand
    {
        private IDockPanel _DockPanel;

        public virtual Plugin Plugin
        {
            get { return null; }
        }

        public virtual IDockPanel DockPanel
        {
            get { return _DockPanel; }
        }

        public override void Run()
        {
            if (Plugin.Owner!=null)
            {
                _DockPanel = Plugin.Owner as IDockPanel;
            }
            else
            {
                _DockPanel = Plugin.Addin.Bulid(Plugin, MainForm.Instance.DockManagerUI) as IDockPanel;
            }
            if (_DockPanel!=null)
            {
                _DockPanel.ShowPanel();
            }
        }
    }
}